package com.lzp.copyui.rv

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.lzp.copyui.R
import com.lzp.copyui.databinding.ItemSnapHelperBinding
import com.utils.OsUtils
import com.utils.SizeUtils

/**
 * @describe:
 * @Author: lixiaopeng
 * @Date: 2021/5/19
 */
class SnapHelperAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        val inflate = LayoutInflater.from(parent.context).inflate(R.layout.item_snap_helper, parent, false)
        inflate.layoutParams = ViewGroup.LayoutParams(OsUtils.getWinWide(parent.context)/3,OsUtils.getWinWide(parent.context)/3)
        return ViewHolder(inflate)
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val viewHolder = holder as ViewHolder
        holder.itemView.tag = position
        viewHolder.binding.tv.text = position.toString()
    }

    override fun getItemCount(): Int {
        return 12
    }

    private class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
        val binding:ItemSnapHelperBinding = ItemSnapHelperBinding.bind(view)
    }
}